package com.base.lib.ui.dialog;

import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.base.lib.R;


/**
 * @author neo.duan
 * @date 2019/09/09
 * @desc 自定义Loading加载框
 */
public class LoadingDialog extends AlertDialog {

    private Context mContext;
    private View mContentView;
    private TextView mTvMsg;

    public LoadingDialog(Context context) {
        super(context, R.style.LoadingTheme);
        mContext = context;
        initView();
    }

    private void initView() {
        mContentView = View.inflate(mContext, R.layout.dialog_loading, null);
        mTvMsg = mContentView.findViewById(R.id.tv_dialog_loading);

        //设置不可取消，点击其他区域不能取消
        setCancelable(false);
        setCanceledOnTouchOutside(false);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(mContentView);
    }

    @Override
    public void setMessage(CharSequence message) {
        mTvMsg.setText(message);
    }
}
